package com.qianfeng.smartdevice.controller.advices;

import com.qianfeng.smartdevice.dto.R;
import com.qianfeng.smartdevice.exceptions.MyBaseException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

 /**
 * @time: 2022-03-17 10:50
 */
@RestControllerAdvice
public class MyErrorAdvice {

    @ExceptionHandler(MyBaseException.class)
    public R processMyBaseException(MyBaseException e) {
        e.printStackTrace();
        return R.getR(e.getCode(), e.getMessage(), null);
    }
     @ExceptionHandler(Exception.class)
     public R processMyBaseException(Exception e){
         e.printStackTrace();
         return R.getR(MyErrorCode.FAIL,"您的网络有异常,请检查后重新测试链接",null);
     }
}
